local file = assert(io.open("luaBox2D.cpp", "r+"))
local str = file:read("*all")
file:close()

--print(str)
strRet = string.gsub(str, "LUA_FUNCTION nHandler = %*%(%(LUA_FUNCTION%*%)  tolua_tousertype%(tolua_S,2,0%)%);", "int nHandler = (tolua_ref_function(tolua_S,2,0));")
--print(strRet)

strRet = string.gsub(strRet, "!tolua_isusertype%(tolua_S,2,\"LUA_FUNCTION\",0,&tolua_err%)%)", "!tolua_isfunction(tolua_S,2,&tolua_err))")
--print(strRet)

file = assert(io.open("luaBox2D.cpp", "w+"))
file:write(strRet)
file:close()

file = assert(io.open("MyGame.cpp", "r+"))
str = file:read("*all")
file:close()

--print(str)
strRet = string.gsub(str, "LUA_FUNCTION nHandler = %*%(%(LUA_FUNCTION%*%)  tolua_tousertype%(tolua_S,2,0%)%);", "int nHandler = (tolua_ref_function(tolua_S,2,0));")
--print(strRet)

strRet = string.gsub(strRet, "!tolua_isusertype%(tolua_S,2,\"LUA_FUNCTION\",0,&tolua_err%)%)", "!tolua_isfunction(tolua_S,2,&tolua_err))")
--print(strRet)

file = assert(io.open("MyGame.cpp", "w+"))
file:write(strRet)
file:close()


